package com.htfyun.serialport.uartservo.AX12_ServoUpdate;

import com.htfyun.serialport.uartservo.IServoReadDataAnalyze;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;

//FD FD ID 0x07 0x00 当前已写字节数(4个byte)当前步骤(1个byte) 校验
//FD FD ID length(2bytes) 当前已写字节数(4个byte) 当前步骤(1个byte) 校验(1byte)
public class AX12Update_ServoReadDataAnalyze extends IServoReadDataAnalyze<AX12Update_ReceivedSerialPacket> {

    @Override
    protected AX12Update_ReceivedSerialPacket createReceivedSerialPacket(ByteBuffer byteBuffer) {
        return new AX12Update_ReceivedSerialPacket(byteBuffer);
    }

    @Override
    protected ByteBuffer getHeader() {
        return AX12Update_ReceivedSerialPacket.getHeaderByteBuffer();
    }

    @Override
    protected int positionOfPacketLengthOffsetFromHeader() {
        return 3;
    }

    @Override
    protected int numBytesOfPacketLength() {
        return 2;
    }

    @Override
    protected int getMinSizeOfValidPacket() {
        return AX12Update_ReceivedSerialPacket.PACKAGE_SIZE;
    }

    @Override
    protected int getMaxLengthOfPacket() {
        return AX12Update_ReceivedSerialPacket.PACKAGE_SIZE;
    }

    @Override
    protected int getExtraLength() {
        return AX12Update_ReceivedSerialPacket.PACKAGE_SIZE - (0xffff & AX12Update_ReceivedSerialPacket.PACKAGE_DATA_FIXED_LEN);
    }

    @Override
    protected ByteOrder getByteOrder() {
        return ByteOrder.LITTLE_ENDIAN;
    }
}
